/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.UIModel.impl;

import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import uimigration.Interactions.GraphicalRendering;
import uimigration.UIModel.Property;
import uimigration.UIModel.UIModelPackage;
import uimigration.uipositionning.Positionning;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Property</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.UIModel.impl.PropertyImpl#getName <em>Name</em>}</li>
 *   <li>{@link uimigration.UIModel.impl.PropertyImpl#getValue <em>Value</em>}</li>
 *   <li>{@link uimigration.UIModel.impl.PropertyImpl#getValueType <em>Value Type</em>}</li>
 *   <li>{@link uimigration.UIModel.impl.PropertyImpl#getPositionning <em>Positionning</em>}</li>
 *   <li>{@link uimigration.UIModel.impl.PropertyImpl#getRenderingProprety <em>Rendering Proprety</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PropertyImpl extends EObjectImpl implements Property {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected static final String VALUE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValue()
	 * @generated
	 * @ordered
	 */
	protected String value = VALUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getValueType() <em>Value Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValueType()
	 * @generated
	 * @ordered
	 */
	protected static final String VALUE_TYPE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getValueType() <em>Value Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getValueType()
	 * @generated
	 * @ordered
	 */
	protected String valueType = VALUE_TYPE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getPositionning() <em>Positionning</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPositionning()
	 * @generated
	 * @ordered
	 */
	protected Positionning positionning;

	/**
	 * The cached value of the '{@link #getRenderingProprety() <em>Rendering Proprety</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRenderingProprety()
	 * @generated
	 * @ordered
	 */
	protected EList<GraphicalRendering> renderingProprety;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PropertyImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return UIModelPackage.Literals.PROPERTY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UIModelPackage.PROPERTY__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getValue() {
		return value;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValue(String newValue) {
		String oldValue = value;
		value = newValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UIModelPackage.PROPERTY__VALUE, oldValue, value));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getValueType() {
		return valueType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValueType(String newValueType) {
		String oldValueType = valueType;
		valueType = newValueType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UIModelPackage.PROPERTY__VALUE_TYPE, oldValueType, valueType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Positionning getPositionning() {
		if (positionning != null && positionning.eIsProxy()) {
			InternalEObject oldPositionning = (InternalEObject)positionning;
			positionning = (Positionning)eResolveProxy(oldPositionning);
			if (positionning != oldPositionning) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, UIModelPackage.PROPERTY__POSITIONNING, oldPositionning, positionning));
			}
		}
		return positionning;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Positionning basicGetPositionning() {
		return positionning;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPositionning(Positionning newPositionning) {
		Positionning oldPositionning = positionning;
		positionning = newPositionning;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UIModelPackage.PROPERTY__POSITIONNING, oldPositionning, positionning));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<GraphicalRendering> getRenderingProprety() {
		if (renderingProprety == null) {
			renderingProprety = new EObjectContainmentEList<GraphicalRendering>(GraphicalRendering.class, this, UIModelPackage.PROPERTY__RENDERING_PROPRETY);
		}
		return renderingProprety;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case UIModelPackage.PROPERTY__RENDERING_PROPRETY:
				return ((InternalEList<?>)getRenderingProprety()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case UIModelPackage.PROPERTY__NAME:
				return getName();
			case UIModelPackage.PROPERTY__VALUE:
				return getValue();
			case UIModelPackage.PROPERTY__VALUE_TYPE:
				return getValueType();
			case UIModelPackage.PROPERTY__POSITIONNING:
				if (resolve) return getPositionning();
				return basicGetPositionning();
			case UIModelPackage.PROPERTY__RENDERING_PROPRETY:
				return getRenderingProprety();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
		@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case UIModelPackage.PROPERTY__NAME:
				setName((String)newValue);
				return;
			case UIModelPackage.PROPERTY__VALUE:
				setValue((String)newValue);
				return;
			case UIModelPackage.PROPERTY__VALUE_TYPE:
				setValueType((String)newValue);
				return;
			case UIModelPackage.PROPERTY__POSITIONNING:
				setPositionning((Positionning)newValue);
				return;
			case UIModelPackage.PROPERTY__RENDERING_PROPRETY:
				getRenderingProprety().clear();
				getRenderingProprety().addAll((Collection<? extends GraphicalRendering>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case UIModelPackage.PROPERTY__NAME:
				setName(NAME_EDEFAULT);
				return;
			case UIModelPackage.PROPERTY__VALUE:
				setValue(VALUE_EDEFAULT);
				return;
			case UIModelPackage.PROPERTY__VALUE_TYPE:
				setValueType(VALUE_TYPE_EDEFAULT);
				return;
			case UIModelPackage.PROPERTY__POSITIONNING:
				setPositionning((Positionning)null);
				return;
			case UIModelPackage.PROPERTY__RENDERING_PROPRETY:
				getRenderingProprety().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case UIModelPackage.PROPERTY__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case UIModelPackage.PROPERTY__VALUE:
				return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
			case UIModelPackage.PROPERTY__VALUE_TYPE:
				return VALUE_TYPE_EDEFAULT == null ? valueType != null : !VALUE_TYPE_EDEFAULT.equals(valueType);
			case UIModelPackage.PROPERTY__POSITIONNING:
				return positionning != null;
			case UIModelPackage.PROPERTY__RENDERING_PROPRETY:
				return renderingProprety != null && !renderingProprety.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", value: ");
		result.append(value);
		result.append(", valueType: ");
		result.append(valueType);
		result.append(')');
		return result.toString();
	}

} //PropertyImpl
